}, tarball);
match publish {
- Ok(invalid_categories) => {
- if !invalid_categories.is_empty() {
+ Ok(warnings) => {
+ if !warnings.invalid_categories.is_empty() {
let msg = format!("\
the following are not valid category slugs and were \
ignored: {}. Please see https://crates.io/category_slugs \
for the list of all category slugs. \
- ", invalid_categories.join(", "));
+ ", warnings.invalid_categories.join(", "));
config.shell().warn(&msg)?;
}
Ok(())
pub name: Option<String>,
}
+pub struct Warnings {
+ pub invalid_categories: Vec<String>,
+}
+
#[derive(RustcDecodable)] struct R { ok: bool }
#[derive(RustcDecodable)] struct ApiErrorList { errors: Vec<ApiError> }
#[derive(RustcDecodable)] struct ApiError { detail: String }
}
pub fn publish(&mut self, krate: &NewCrate, tarball: &File)
- -> Result<Vec<String>> {
+ -> Result<Warnings> {
let json = json::encode(krate)?;
// Prepare the body. The format of the upload request is:
//
x.iter().flat_map(Json::as_string).map(Into::into).collect()
})
.unwrap_or_else(Vec::new);
- Ok(invalid_categories)
+ Ok(Warnings { invalid_categories: invalid_categories })
}
pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec<Crate>, u32)> {